package com.web.dao;

import com.web.entity.ProfitConfig;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface ProfitConfigMapper {
    @Delete({
        "delete from t_profit_config",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_profit_config (company_profit_pool, company_fund_pool, ",
        " market_fund_pool, bonus_pool, ",
        " consume_profit, merchant_profit, ",
        " agent_province, agent_city, ",
        " agent_region, core_points, ",
        " fission, create_time, ",
        " modify_time)",
        " values (#{companyProfitPool,jdbcType=DECIMAL}, #{companyFundPool,jdbcType=DECIMAL}, ",
        " #{marketFundPool,jdbcType=DECIMAL}, #{bonusPool,jdbcType=DECIMAL}, ",
        " #{consumeProfit,jdbcType=DECIMAL}, #{merchantProfit,jdbcType=DECIMAL}, ",
        " #{agentProvince,jdbcType=DECIMAL}, #{agentCity,jdbcType=DECIMAL}, ",
        " #{agentRegion,jdbcType=DECIMAL}, #{corePoints,jdbcType=DECIMAL}, ",
        " #{fission,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, ",
        " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(ProfitConfig record);

    @InsertProvider(type=ProfitConfigSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(ProfitConfig record);

    @Select({
        "select",
        " id, company_profit_pool, company_fund_pool, market_fund_pool, bonus_pool, consume_profit, ",
        " merchant_profit, agent_province, agent_city, agent_region, core_points, fission, ",
        " create_time, modify_time",
        " from t_profit_config",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="company_profit_pool", property="companyProfitPool", jdbcType=JdbcType.DECIMAL),
        @Result(column="company_fund_pool", property="companyFundPool", jdbcType=JdbcType.DECIMAL),
        @Result(column="market_fund_pool", property="marketFundPool", jdbcType=JdbcType.DECIMAL),
        @Result(column="bonus_pool", property="bonusPool", jdbcType=JdbcType.DECIMAL),
        @Result(column="consume_profit", property="consumeProfit", jdbcType=JdbcType.DECIMAL),
        @Result(column="merchant_profit", property="merchantProfit", jdbcType=JdbcType.DECIMAL),
        @Result(column="agent_province", property="agentProvince", jdbcType=JdbcType.DECIMAL),
        @Result(column="agent_city", property="agentCity", jdbcType=JdbcType.DECIMAL),
        @Result(column="agent_region", property="agentRegion", jdbcType=JdbcType.DECIMAL),
        @Result(column="core_points", property="corePoints", jdbcType=JdbcType.DECIMAL),
        @Result(column="fission", property="fission", jdbcType=JdbcType.DECIMAL),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    ProfitConfig selectByPrimaryKey(Long id);

    @UpdateProvider(type=ProfitConfigSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ProfitConfig record);

    @Update({
        "update t_profit_config",
        " set company_profit_pool = #{companyProfitPool,jdbcType=DECIMAL},",
          " company_fund_pool = #{companyFundPool,jdbcType=DECIMAL},",
          " market_fund_pool = #{marketFundPool,jdbcType=DECIMAL},",
          " bonus_pool = #{bonusPool,jdbcType=DECIMAL},",
          " consume_profit = #{consumeProfit,jdbcType=DECIMAL},",
          " merchant_profit = #{merchantProfit,jdbcType=DECIMAL},",
          " agent_province = #{agentProvince,jdbcType=DECIMAL},",
          " agent_city = #{agentCity,jdbcType=DECIMAL},",
          " agent_region = #{agentRegion,jdbcType=DECIMAL},",
          " core_points = #{corePoints,jdbcType=DECIMAL},",
          " fission = #{fission,jdbcType=DECIMAL},",
          " create_time = #{createTime,jdbcType=TIMESTAMP},",
          " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(ProfitConfig record);
}